<?php
include_once('king_head.php');

if("$action"=="Save"){
$color=str_replace("#",'',$color);
$sql="INSERT INTO temp_product(product_title, product_category, product_desc, product_img, product_img_alt, product_price, size, color, added_by) VALUES ('$product_title', '$product_category', '$product_desc', '$product_img_name', '$product_img_alt', '$product_price', '$size', '$color', $_SESSION['SITE_ID'])";
		//echo $sql;
		mysql_query($sql);
		$pid=mysql_insert_id();
		if (isset($product_img) && $product_img != "") {

			if(!copy($product_img,"./photos/Temp_products/${pid}_" . $product_img_name)){ echo "coping error!"; exit;}
	
		}
		echo "<H4><FONT COLOR=red>Product Added to Proposed List.</FONT>!</H4>";
	}
?>
<form name=frm enctype="multipart/form-data"  method="post" action="propose_prod.php?site_id=<?php echo $_SESSION['SITE_ID'];?>">
<input type=hidden name=site_id value="<?php echo $_SESSION['SITE_ID']; ?>">
<table width="100%" border="0" align="center">
  <tr>
    <td height="43" colspan="2"><div align="center">
      <h2>Propose a product </h2>
    </div></td>
    </tr>
  <tr>
    <td width="21%">Product title </td>
    <td width="79%"><input name="product_title" value="<?php echo $product_title; ?>" size="50" maxlength="100" />
      &nbsp;</td>
  </tr>
  <tr>
    <td>Product category</td>
    <td><select name="product_cat_id" onchange="javascript:document.frm.product_category.value=document.frm.product_cat_id[document.frm.product_cat_id.selectedIndex].value;">
      <?php
	
	$sql="SELECT DISTINCT(product_category) as product_category FROM product_master WHERE product_category!='' ORDER BY product_category";

	$result = mysql_query($sql);
	while($row=mysql_fetch_array($result)){
		$product_cat=$row["product_category"];
		if($product_cat == $product_category) $set="selected";
		else $set="";
		echo "<option value='$product_cat' $set>$product_cat";
	}
?>
    </select>
      &nbsp;
      <input name="product_category" value="<?php echo $product_category; ?>" size="25" maxlength="30" /></td>
  </tr>
  <tr>
    <td>Product description<br />
        <font size="1">(You can enter<br />
          content in<br />
          HTML format)</font></td>
    <td><textarea name="product_desc" rows="10" cols="40"><?php echo $product_desc; ?></textarea></td>
  </tr>
  <tr>
    <td>Product Image </td>
    <td><input  type="file" name="product_img" value="" size="20" /></td>
  </tr>
  <tr>
    <td>Product Image alt </td>
    <td><input name="product_img_alt" value="<?php echo $product_img_alt; ?>" size="40" /></td>
  </tr>
  <tr>
    <td>Product price </td>
    <td><input name="product_price" value="<?php echo $product_price; ?>" size="40" maxlength="8" /></td>
  </tr>
  <tr>
    <td>Size</td>
    <td><input name="size" value="<?php echo $size; ?>" size="40" maxlength="8" /></td>
  </tr>  
  <tr>
    <td>Color</td>
    <td><input name="color" value="<?php echo $color; ?>" size="40" maxlength="8" /><?php pk_color('color',1);?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type=submit name=action value=Save></td>
  </tr>
</table>
</form>
<?php include_once('king_foot.php');?>